﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Cloud.Model;
using Cloud.BLL;

public partial class Three_Managerment_Problem_three_Edit2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (Session["users"] == null)
            {
                Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            }

            if (IsPostBack)
            {

            }
            else
            {
                Yqsq asc = YqsqManager.FindById(Convert.ToInt32(Request.QueryString["id"]));
                int id = asc.Sjid;
                Problem activity = ProblemManager.FindById(id);
                if (activity != null)
                {
                    this.sjbh.InnerText = activity.Appealid.ToString();
                    this.sbsj.InnerText = activity.Regtime.ToString();
                    if (activity.Secrecy.Equals("0"))
                    {
                        this.xm.InnerText = activity.Appeal_name.ToString();
                        this.lxfs.InnerText = activity.Appeal_tel;
                    }
                    else
                    {
                        this.xm.InnerText = "****信息已加密****";
                        this.lxfs.InnerText = "****信息已加密****";
                    }
                    this.lab_xbsj.InnerText = activity.Xbtime == new DateTime(1900, 01, 01, 00, 00, 00) ? "无限办时间" : activity.Xbtime.ToString();
                    this.gs.InnerText = AscriptionManager.FindById(activity.Ascription_id).Name;
                    this.dl.InnerText = Classification_Appeal1Manager.FindById(activity.Appeal_type_id).Name;
                    this.xl.InnerText = Classification_Appeal2Manager.FindById(activity.Xialei).Name;
                    this.yx.InnerText = activity.Appeal_email;
                    this.bt.InnerText = activity.Title;
                    this.nr.InnerText = activity.Context;
                    this.gh.InnerText = activity.Jobnum.ToString();
                    if (activity.Current_ld == 0)
                    {
                        dbm.InnerText = "一级部门办理中";
                    }
                    else if (activity.Current_ld == 1)
                    {
                        dbm.InnerText = "二级部门办理中";
                    }
                    else if (activity.Current_ld == 2)
                    {
                        dbm.InnerText = "三级部门办理中";
                    }
                    this.repeater.DataSource = Problem_historic2Manager.FindBysj(activity.Appealid);
                    this.repeater.DataBind();
                    this.div.Visible = false;

                    this.lab_yqz.InnerText = asc.Times.ToString();
                    this.lab_dw2.InnerText = ZS_TYPEINFOManager.FindById(asc.Zrdwid).NAME;
                    this.lab_dw3.InnerText = asc.Bldwid.ToString().Equals("") ? "无三级单位" : DWManager.FindById(asc.Bldwid).DWMC;
                    if (Request.QueryString["type"].Equals("yanqi"))
                    {
                        activity.Handle_type = 1;
                        activity.Islook0 = 1;
                        ProblemManager.Update(activity);
                    }
                }
            }
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }
    protected void yanqi_btn_Click(object sender, EventArgs e)
    {
        if (Session["users"] == null)
        {
            Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
        }

        //Yqsq asc = YqsqManager.FindById(Convert.ToInt32(Request.QueryString["id"]));
        //asc.Bm0_type = 1;


        Response.Write("<script>history.go(-1)</script>");
    }
    public String sjlx(int id)
    {
        String res = "";
        if (id == 0)
        {
            res = "受理";
        }
        else if (id == 1)
        {
            res = "派遣";
        }
        else if (id == 2)
        {
            res = "直办";
        }
        else if (id == 3)
        {
            res = "反馈";
        }
        else if (id == 4)
        {
            res = "审核";
        }
        else if (id == 5)
        {
            res = "驳回";
        }
        else if (id == 6)
        {
            res = "督办";
        }
        else if (id == 7)
        {
            res = "延期";
        }
        else if (id == 8)
        {
            res = "办结";
        }
        else if (id == 9)
        {
            res = "申请办结";
        }
        return res;
    }
    public String dwxx(String id)
    {
        try
        {
            String res = "";
            if (id.Length == 6)
            {
                if (DWManager.FindById(id) == null)
                {
                    res = ZS_TYPEINFOManager.FindById(id).NAME;
                }
                else
                {

                    res = DWManager.FindById(id).DWMC;
                }
            }
            else
            {
                if (ZS_TYPEINFOManager.FindById(id) != null)
                {
                    res = ZS_TYPEINFOManager.FindById(id).NAME;
                }
                else
                {
                    res = DWManager.FindById(id).DWMC;
                }

            }
            return res;
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            return "";
        }
    }
    protected void repeater_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        try
        {
            if (Session["users"] == null)
            {
                Response.Write("<script>alert('请先登录！');window.parent.parent.location.href='/Login.aspx'</script>");
            }
            else
            {
                this.div.Visible = true;
                if (e.CommandName.Equals("links"))
                {
                    Problem_historic2 his2 = Problem_historic2Manager.FindById(Convert.ToInt32(e.CommandArgument));
                    this.lab_title.InnerText = his2.Title;
                    this.lab_slr.InnerText = his2.Name;
                    this.lab_hf.InnerText = his2.Blyj;
                }
            }
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }
    //同意延期
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            Yqsq asc = YqsqManager.FindById(Convert.ToInt32(Request.QueryString["id"]));
            Problem adc = ProblemManager.FindById(asc.Sjid);
            asc.Bm0_type = 0;
            adc.Xbtime = asc.Times;

            if (ProblemManager.Update(adc) > 0)
            {
                YqsqManager.Update(asc);

                Problem_historic2 his = new Problem_historic2();
                his.Blyj = "";
                his.Title = "延期申请，同意延期 ";
                his.Bm2 = "";
                his.Evente = 7; //
                his.Idopen = adc.Appealid;


                his.Bm1 = ((USER_INFO)Session["users"]).DEPARTMENT;
                his.Item1 = 0;
                his.Item2 = "";
                his.Item3 = "";
                his.Name = ((USER_INFO)Session["users"]).USER_NAME;
                his.Times = DateTime.Now;
                his.Timese = asc.Times;

                Problem_historic2Manager.Save(his);
            }

        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }
}